default_platform :ios

platform :ios do

  before_all do
    setup_circle_ci
  end

  desc "Run code linter"
  lane :lint do
  	swiftlint(
  		mode: :lint,
   		config_file: '.swiftlint.yml',
      reporter: 'emoji',
      raise_if_swiftlint_error: true
  	)
  end

  desc "Runs all the tests"
  lane :test do |options|
    scheme = options[:scheme]
    device = options[:device]
    scan(
      scheme: scheme,
      device: device,
      clean: true,
      skip_build: true,
      output_types: 'junit'
      )
  end

  desc "Cocoapods library lint"
  lane :pod_lint do
    pod_lib_lint(verbose: false, allow_warnings: true)
  end

  desc "Runs all the tests in a CI environment"
  lane :ci do
    # TODO: Run rest of platforms
    lint
    test
  end
  
  desc "Tags the release and pushes the Podspec to CocoaPods"
  lane :release do
    perform_release target: 'JWTDecode-iOS'
    publish_release repository: 'JWTDecode.swift'
  end
end
